package com.tudouji.project.product.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.product.domain.Suitpack;
import com.tudouji.project.product.service.ISuitpackService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 套装定义Controller
 * 
 * @author tudouji
 * @date 2022-06-27
 */
@RestController
@RequestMapping("/product/suitpack")
public class SuitpackController extends BaseController
{
    @Autowired
    private ISuitpackService suitpackService;

    /**
     * 查询套装定义列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Suitpack suitpack)
    {
        startPage();
        List<Suitpack> list = suitpackService.selectSuitpackList(suitpack);
        return getDataTable(list);
    }

    /**
     * 导出套装定义列表
     */
    @PreAuthorize("@ss.hasPermi('product:suitpack:export')")
    @Log(title = "套装定义", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Suitpack suitpack)
    {
        List<Suitpack> list = suitpackService.selectSuitpackList(suitpack);
        ExcelUtil<Suitpack> util = new ExcelUtil<Suitpack>(Suitpack.class);
        return util.exportExcel(list, "suitpack");
    }

    /**
     * 获取套装定义详细信息
     */
    @PreAuthorize("@ss.hasPermi('product:suitpack:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(suitpackService.selectSuitpackById(guid));
    }

    /**
     * 新增套装定义
     */
    @PreAuthorize("@ss.hasPermi('product:suitpack:add')")
    @Log(title = "套装定义", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Suitpack suitpack)
    {
        return toAjax(suitpackService.insertSuitpack(suitpack));
    }

    /**
     * 修改套装定义
     */
    @PreAuthorize("@ss.hasPermi('product:suitpack:edit')")
    @Log(title = "套装定义", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Suitpack suitpack)
    {
        return toAjax(suitpackService.updateSuitpack(suitpack));
    }

    /**
     * 删除套装定义
     */
    @PreAuthorize("@ss.hasPermi('product:suitpack:remove')")
    @Log(title = "套装定义", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(suitpackService.deleteSuitpackByIds(guids));
    }


}
